package com.fsquare.inventory.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.broadleafcommerce.common.presentation.AdminPresentation;
import org.broadleafcommerce.common.presentation.AdminPresentationClass;
import org.broadleafcommerce.common.presentation.PopulateToOneFieldsEnum;
import org.broadleafcommerce.core.catalog.domain.Sku;
import org.broadleafcommerce.core.catalog.domain.SkuImpl;
import org.broadleafcommerce.profile.core.domain.Customer;
import org.broadleafcommerce.profile.core.domain.CustomerImpl;

@Entity
@Table(name = "SKU_MOVEMENT")
@AdminPresentationClass(populateToOneFields = PopulateToOneFieldsEnum.TRUE, friendlyName = "productMovements")
public class SkuMovementImpl implements SkuMovement {
	
	@Id
	@GeneratedValue
    private Long id;
	
	@Column(name = "QUANTITY", nullable=false)
	@AdminPresentation
    protected Integer quantity = 0;
    
	@OneToOne(optional = false, targetEntity = SkuImpl.class)
	@JoinColumn(name = "SKU_ID", referencedColumnName = "SKU_ID")
    protected Sku sku;

    @Column(name = "UPDATE_DATE")
    @AdminPresentation
    protected Date updateDate;
    
    @Column(name = "MOVEMENT_TYPE")
    @Enumerated(EnumType.STRING)
    @AdminPresentation
    protected MovementType movementType;
    
    @Column(name = "DESCRIPTION")
    @AdminPresentation
    protected Date description;
    
    @ManyToOne(optional = true, targetEntity = CustomerImpl.class)
	@JoinColumn(name = "customer_id", referencedColumnName = "CUSTOMER_ID", nullable=true)
    protected Customer customer;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Sku getSku() {
		return sku;
	}

	public void setSku(Sku sku) {
		this.sku = sku;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public MovementType getMovementType() {
		return movementType;
	}

	public void setMovementType(MovementType movementType) {
		this.movementType = movementType;
	}

	public Date getDescription() {
		return description;
	}

	public void setDescription(Date description) {
		this.description = description;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
    
}
